package com.fulin.thread.task;

public class TestVolatile {
	public volatile int inc = 0;
	
	public void increase(){
		inc ++;
	}
	
	public static void main(String[] args) {
		final TestVolatile test = new TestVolatile();
		for(int i = 0 ;i<10;i++){
			new Thread(){
				@Override
				public void run() {
					for(int j = 0;j<1000;j++){
						test.increase();
					}
				}
			}.start();
		}
		
		while(Thread.activeCount() > 1){
			Thread.yield();
		}
		System.out.println(test.inc);
	}
}
